package com.quick.admin.controller;

import com.alibaba.fastjson.JSONObject;
import com.quick.admin.service.AdminUserService;
import com.quick.common.dto.SearchUserDto;
import com.quick.common.result.ResultEntity;
import com.quick.common.validator.RequiresPermissionsDesc;
import org.apache.tomcat.util.http.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 胡通达
 * @version 1.0
 * @date 2021-01-27 15:47
 */
@RestController
@RequestMapping("/admin/adminStoreUser")
public class AdminUserController {

    @Autowired
    private AdminUserService adminUserService;

    //    @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"用户管理", "普通用户"}, button = "查询")
    @PostMapping("/searchGeneralUserList")
    public ResultEntity<Map<String, Object>> searchGeneralUserList(@RequestBody SearchUserDto searchUserDto) {
        Map<String, Object> data = adminUserService.searchGeneralUserList(searchUserDto);
        return ResultEntity.ok(data);
    }


    @RequiresPermissionsDesc(menu = {"用户管理", "有效会员"}, button = "查询")
    @PostMapping("/searchMemberUserList")
    public ResultEntity<Map<String, Object>> searchMemberUserList(@RequestBody SearchUserDto searchUserDto) {
        Map<String, Object> data = adminUserService.searchMemberUserList(searchUserDto);
        return ResultEntity.ok(data);
    }

    @RequiresPermissionsDesc(menu = { "用户管理", "到期会员" }, button = "查询")
    @PostMapping("/searchNotMemberUserList")
    public ResultEntity<Map<String, Object>> searchNotMemberUserList(@RequestBody SearchUserDto searchUserDto) {
        Map<String, Object> data = adminUserService.searchNotMemberUserList(searchUserDto);
        return ResultEntity.ok(data);
    }

}
